package service;

import dao.EntityDAO;
import dao.EntityDAOImpl;
import tool.DatabaseConnection;

import java.sql.SQLException;

import javax.naming.NamingException;

public class EntityServiceImpl implements EntityService {
    private EntityDAO entityDAO;
    {
        try {
            entityDAO = new EntityDAOImpl(DatabaseConnection.getConnection());
        } catch (NamingException | SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    public int register(String name) throws SQLException, NamingException {
        return entityDAO.add(name);
    }

    @Override
    public int inquire(String name) throws SQLException, NamingException {
        return entityDAO.query(name);
    }
}
